#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/12/1 12:19
# @Author  : 吴敬超
# @Site    : 
# @File    : py2.py
# @Software: PyCharm
import netCDF4
import seaborn as seaborn
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# import cartopy.crs as ccrs

# file_path_wrf = "E:\\clm201\\SALT_B.E.13.B1850C5.ne120_t12.sehires38.003.sunway_02.pop.h.0022-06.nc"
file_path_wrf = "E:\\ehlocean\\data\\TEMPSALT\\TEMP_B.E.13.B1850C5.ne120_t12.sehires38.003.sunway_02.pop.h.0021-01.nc"

# open a local NetCDF file or remote OPeNDAP URL
nc = netCDF4.Dataset(file_path_wrf)

# examine the variables
# print nc.variables.keys()
# print nc.variables['SALT']

# sample every 10th point of the 'z' variable
# topo = nc.variables['SALT'][0][0][:][:]
topo = nc.variables['TEMP'][0][0][:][:]

# ax=plt.gca()  #gca:get current axis得到当前轴
# #设置图片的右边框和上边框为不显示
# ax.spines['right'].set_color('none')
# ax.spines['top'].set_color('none')

# make image
# plt.set_cmap()
# plt.colorbar(color=seaborn.xkcd_rgb['baby poop green'])

# plt.figure(figsize=(36,18))
# alpha = 0
# figalpha = plt.figure()
# figalpha.patch.set_alpha(alpha)

plt.rcParams['figure.figsize'] = (36.0, 18.0)  # 单位是inches
# m = Basemap(lon_0=0, lat_0=0)

#
# m = Basemap(
#             llcrnrlat=-90, urcrnrlat=90,
#             llcrnrlon=-180, urcrnrlon=180)
# m = Basemap(llcrnrlon=108.6,
#             llcrnrlat=24.5,
#             urcrnrlon=114.3,
#             urcrnrlat=30.2,
#             resolution=None,
#             projection='cyl')
#
fig, ax = plt.subplots()

# 去掉框
ax.spines['top'].set_visible(False)
# 下面
ax.spines['bottom'].set_visible(False)
# 左边
ax.spines['left'].set_visible(False)
# 右边
ax.spines['right'].set_visible(False)
# 去掉等分线
plt.xticks([])
plt.yticks([])
# plt.xlim([-1800,1800])
# plt.ylim([-900,900])

# extent = (-180,180,-90,90)
plt.imshow(topo, origin='lower', cmap="jet", aspect='auto')
# plt.subplots_adjust(left=0.0, right=0.0, top=0.0, bottom=0.0)
# plt.title(nc.title)
# transparent=True  设置透明
plt.savefig('imageTEMP11111.png', transparent=True, bbox_inches=0)
plt.close()
